#-------------------------------------------------------------------------------
# @brief Sensor Hub demo auto rotate (header file)
#
# @note
# Copyright(C) NXP Semiconductors, 2015
# All rights reserved.
#
# @par
# Software that is described herein is for illustrative purposes only
# which provides customers with programming information regarding the
# LPC products.  This software is supplied "AS IS" without any warranties of
# any kind, and NXP Semiconductors and its licensor disclaim any and
# all warranties, express or implied, including all implied warranties of
# merchantability, fitness for a particular purpose and non-infringement of
# intellectual property rights.  NXP Semiconductors assumes no responsibility
# or liability for the use of the software, conveys no license or rights under any
# patent, copyright, mask work right, or any other intellectual property rights in
# or to any products. NXP Semiconductors reserves the right to make changes
# in the software without notification. NXP Semiconductors also makes no
# representation or warranty that such application will be suitable for the
# specified use without further testing or modification.
#
# @par
# Permission to use, copy, modify, and distribute this software and its
# documentation is hereby granted, under NXP Semiconductors' and its
# licensor's relevant copyrights in the software, without fee, provided that it
# is used in conjunction with NXP Semiconductors microcontrollers.  This
# copyright, permission, and disclaimer notice must appear in all copies of
# this code.
#-------------------------------------------------------------------------------

#-------------------------------------------------------------------------------
#	Pattern rules
#-------------------------------------------------------------------------------
%.o: %.c
	@echo gcc: $@ | sed 's/\(.*\).o/\1/'
	@$(CC) -c $(CFLAGS) $(CPPFLAGS) -o $@ $<

LINK.c = $(CC) $(LDFLAGS) $(TARGET_ARCH)

%: %.o
	@echo ld: $@
	@$(LINK.c) $^ $(LOADLIBES) $(LDLIBS) -o $@

#-------------------------------------------------------------------------------
#	Environment
#-------------------------------------------------------------------------------
CFLAGS		= -Wall -Werror -ggdb -std=gnu99
LDLIBS		= -L. -lpopt -lfreeglut -lglu32 -lopengl32 -l../lpcusbsio
LDLIBS_WIN	= -L. -lpopt -lfreeglut -lglu32 -lopengl32 -l../lpcusbsio -Wl,--subsystem,windows

#-------------------------------------------------------------------------------
#	Targets
#-------------------------------------------------------------------------------
TARGET		=	sensor_demo

OBJS		=	sensor_demo.o gl_callback.o gl_menu.o gl_text.o sensorhal.o		\
				auto_rotate.o teapot.o sensors.o misc.o trace.o i2c_io.o		\
				sio_info.o recorder.o stat_acc.o sio_cmd.o

#-------------------------------------------------------------------------------
#	Rules
#-------------------------------------------------------------------------------
.PHONY:		all clean format install

all:		$(TARGET) install sensor_demo_w

clean:;		$(RM) *.o
			$(RM) *.bak
			$(RM) *.exe
			$(RM) *.c.orig
			$(RM) *.h.orig

format:;	astyle --style="k&r" --indent=tab --lineend=windows --recursive "*.c" "*.h"

install:;	cp $(TARGET) ..

#-------------------------------------------------------------------------------
#	Dependencies
#-------------------------------------------------------------------------------
sensor_demo_w:		$(OBJS)					
					@$(LINK.c) $^ $(LOADLIBES) $(LDLIBS_WIN) -o $@
					cp $@ ../install

sensor_demo:		$(OBJS)

sensor_demo.o:		sensor_demo.h

gl_callback.o:		gl_callback.h

gl_menu.o:			gl_menu.h

gl_text.o:			gl_text.h

sensorhal.o:		sensorhal.h

auto_rotate.o:		auto_rotate.h

teapot.o:			teapot.h

sensors.o:			sensors.h

misc.o:				misc.h

trace.o:			trace.h

i2c_io.o:			i2c_io.h

sio_info.o:			sio_info.h

recorder.o:			recorder.h

stat_acc.o:			stat_acc.h
